from DataManagement.models import DataCenterModel
from gxdm.models import *
from gxxx.models import *
from gxxs.models import Gxxs0101


class Gxxs0701(DataCenterModel):
    # xh = models.CharField(primary_key=True, max_length=32, verbose_name='学号')
    xh = models.OneToOneField(Gxxs0101, to_field='xh', on_delete=models.PROTECT, related_name='gxxs0701', db_column='xh', verbose_name='学号', primary_key=True)
    rxny = models.CharField(max_length=32, blank=True, null=True, verbose_name='入学年月')
    # xslbm = models.CharField(max_length=32, blank=True, null=True, verbose_name='学生类别码')
    xslbm = models.ForeignKey(Xslbdm, to_field='value', related_name='xs_01_xslbm', on_delete=models.PROTECT,
                              db_column='xslbm', verbose_name="学生类别码", blank=True, null=True)

    xz = models.IntegerField(blank=True, null=True, verbose_name='学制')
    # szbh = models.CharField(max_length=32, blank=True, null=True, verbose_name='所在班号')
    szbh = models.ForeignKey(Gxxx04, to_field='bh', related_name='xs_0701_szbh', on_delete=models.PROTECT, db_column='szbh', verbose_name="所在班号", blank=True, null=True)
    sznj = models.CharField(max_length=32, blank=True, null=True, verbose_name='所在年级')
    yxsh = models.ForeignKey(Dwbmdm, to_field='value', related_name='xs_01_yxsh', on_delete=models.PROTECT,
                              db_column='yxsh', verbose_name="院系所号", blank=True, null=True)
    deyxmc = models.CharField(max_length=32, blank=True, null=True, verbose_name='第二院系名称')
    # zym = models.CharField(max_length=32, blank=True, null=True, verbose_name='专业码')
    zym = models.ForeignKey(Gxxx06, to_field='zybh', related_name='xs_0701_zym', on_delete=models.PROTECT, db_column='zym', verbose_name="专业码", blank=True, null=True)
    xkmlm = models.CharField(max_length=32, blank=True, null=True, verbose_name='学科门类码')
    pyfsm = models.CharField(max_length=32, blank=True, null=True, verbose_name='培养方式码')
    yjfx = models.CharField(max_length=32, blank=True, null=True, verbose_name='研究方向')
    dsh = models.CharField(max_length=32, blank=True, null=True, verbose_name='导师号')
    hdxlfsm = models.CharField(max_length=32, blank=True, null=True, verbose_name='获得学历方式码')
    sfxfz = models.CharField(max_length=32, blank=True, null=True, verbose_name='是否学分制')
    pyccm = models.CharField(max_length=32, blank=True, null=True, verbose_name='培养层次码')
    ldfsm = models.CharField(max_length=32, blank=True, null=True, verbose_name='连读方式码')
    xsdqztm = models.CharField(max_length=32, blank=True, null=True, verbose_name='学生当前状态码')
    xsdqztm = models.ForeignKey(Xsdqztdm, to_field='value', related_name='xs_01_xsdqztm', on_delete=models.PROTECT,
                              db_column='xsdqztm', verbose_name="学生当前状态码", blank=True, null=True)

    def __str__(self):
        if self.xh:
            return self.xh.xh
        else:
            return None

    class Meta:
        managed = False
        db_table = 'gxxs0701'
        verbose_name = 'GXXS0701 学籍基本数据子类表'
        verbose_name_plural = 'GXXS0701 学籍基本数据子类表'
